@extends('admin.main')
@section('head')
    <style>
        .buyer {
            color: #555;
            position: relative;
            display: block;
        }

        .buyer-info {
            display: none;
            width: 400px
        }

        .buyer:hover .buyer-info {
            *width: 250px /*IE7*/;
            display: block;
            position: absolute;
            z-index: 8;
            top: -40px;
            left: 40px;
            border: solid 1px #FEC500;
            background-color: #FFF9D4;
            padding: 4px;
            border-radius: 5px;
        }

        .buyer-info em {
            width: 8px;
            height: 14px;
            position: absolute;
            z-index: 9;
            top: 37px;
            left: -8px;
        }

        .buyer-info .con {
            display: block;
            overflow: hidden;
            background: #FFF;
            padding: 5px;
        }

        .buyer-info h3 {
            font-size: 1em;
            font-weight: 700;
            color: #C33700;
            padding: 5px 0;
            overflow: hidden;
        }

        .buyer-info h3 i {
            width: 17px;
            height: 11px;
            float: left;
            margin: 5px 5px 4px 12px;
        }

        .buyer-info h3 span {
            float: left;
        }

        .buyer-info dl {
            color: #777;
            padding: 2px 0;
            width: 420px;
            overflow: hidden;
            clear: both;
        }

        .buyer-info dt {
            float: left;
            width: 100px;
            text-align: right;
        }

        .buyer-info dd {
            float: left;
            width: 320px;
            text-align: left;
        }

        .select_box {
            position: relative;
            padding: 0;
            display: inline-block;
            zoom: 1;
            *zoom: 1;
            *display: inline;
        }

        .select_box input:hover {
        }

        .select_box ul {
            width: 150px;
            position: absolute;
            left: 0;
            top: 28px;
            border: 1px solid #85BEE5;
            overflow: hidden;
            display: none;
            background: white;
            z-index: 9999;
        }

        .select_box ul li {
            display: block;
            height: 25px;
            overflow: hidden;
            line-height: 25px;
            padding-left: 5px;
            width: 100%;
            cursor: pointer;
        }

        .select_box ul li:hover {
            background: #d2eaff;
        }


    </style>
@endsection
@section('body')
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>商户列表</h2>
    </div>
    <div class="cf">
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div style="float: left;margin-right: 10px;line-height: 26px;">
                <select name="type" id="type" style="height: 30px;">
                    <option value="0" @if($type == 0) selected @endif>请选择搜索类型</option>
                    <option value="2" @if($type == 2) selected @endif>店铺名</option>
                    <option value="3" @if($type == 3) selected @endif>姓名</option>
                    <option value="4" @if($type == 4) selected @endif>手机号</option>
                    <option value="5" @if($type == 5) selected @endif>地址</option>
                    <option value="6" @if($type == 6) selected @endif>商户号</option>
                </select>
            </div>
            <div class="sleft">
                <input type="text" name="keyword" class="search-input" value="{{request('keyword')}}"
                       placeholder="请输入对应的搜索内容">
                <a class="sch-btn" href="javascript:;" id="search" url="{{urlAdmin('saoPay','getIndex')}}"><i
                            class="btn-search"></i></a>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="">ID</th>
                <th class="">商户号</th>
                <th class="">店铺名</th>
                <th class="">姓名</th>
                <th class="">手机号</th>
                <th class="">地址</th>
                <th class="">操作</th>
            </tr>
            </thead>
            <tbody>
            @if(count($rows['data']))
                @foreach($rows['data'] as $v)
                    <tr>
                        <td><input class="ids" type="checkbox" name="ids[]" value="{{$v['id']}}"/></td>
                        <td>{{$v['id']}}</td>
                        <td>{{$v['sao_pay'] ? $v['sao_pay']['merchant_no'] : ''}}</td>
                        <td>{{$v['shop_name']}}</td>
                        <td>{{$v['boss_name']}}</td>
                        <td>{{$v['shop_phone']}}</td>
                        <td>{{$v['area_info'].' '.$v['address']}}</td>
                        <td>
                            <a title="支付配置"
                               href="{{urlAdmin('saoPay','getEdit',['shop_id'=>$v['id'],'pay_id'=>($v['sao_pay'] ? $v['sao_pay']['id'] : 0)])}}">支付配置</a>
                        </td>
                    </tr>
                @endforeach
            @else
                <td colspan="15" class="text-center"> aOh! 暂时还没有内容!</td>
            @endif
            </tbody>
        </table>
    </div>
    <div class="page">
        @if($rows['last_page']>1)
            <div>
                <a class="first" href="{{urlAdmin('saoPay','getIndex',['page'=>1,'keyword'=>$keyword,'type'=>$type])}}">首页</a>
                @if($rows['prev_page_url'])
                    <a class="prev" href="{{$rows['prev_page_url']}}&keyword={{$keyword}}&type={{$type}}">&lt;&lt;</a>
                @endif
                @if(count($rows['pageNoList']))
                    @foreach($rows['pageNoList'] as $v)
                        @if($rows['current_page'] == $v)
                            <span class="current">{{$v}}</span>
                        @else
                            <a class="num" href="{{urlAdmin('saoPay','getIndex',['page'=>$v,'keyword'=>$keyword,'type'=>$type])}}">{{$v}}</a>
                        @endif
                    @endforeach
                @endif
                @if($rows['next_page_url'])
                    <a class="next" href="{{$rows['next_page_url']}}&keyword={{$keyword}}&type={{$type}}">&gt;&gt;</a>
                @endif
                <a class="last" href="{{urlAdmin('saoPay','getIndex',['page'=>$rows['last_page'],'keyword'=>$keyword,'type'=>$type])}}">末页</a>
                <span class="rows">共 {{$rows['total']}}条记录</span>
            </div>
        @endif
    </div>
@endsection

@section('script')
    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var shop_id = $("#sch-sort-txt").attr("data");
            var query = $('.search-form').find('input').serialize();
            var type = $('#type').val();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query + '&type=' + type;
            } else {
                url += '?' + query + '&type=' + type;
            }
            window.location.href = url;
        });

        //回车自动提交
        $('.search-form').find('input').keyup(function(event){
            if(event.keyCode===13){
                $("#search").click();
            }
        });

        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down").hover(function () {
            $("#sub-sch-menu").removeClass("hidden");
        }, function () {
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function () {
            $(this).click(function () {
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data", $(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
                var shop_id = $(this).attr("value");
                if (shop_id) {
                    window.location.href = '{{urlAdmin('shopGoods','getIndex')}}?shop_id=' + shop_id;
                    return;
                }
                window.location.href = '{{urlAdmin('saoPay','getIndex')}}';
            })
        });

        $(".more").click(function () {
            var thisul = $(this).parent().find("ul");
            if (thisul.css("display") == "none") {
                if (thisul.height() > 180) {
                    thisul.css({height: "180" + "px", "overflow-y": "scroll"})
                }
                ;
                thisul.fadeIn("100");
                thisul.hover(function () {
                }, function () {
                    thisul.fadeOut("100");
                })
                thisul.find("li").click(function () {
                    thisul.fadeOut("100");
                }).hover(function () {
                    $(this).addClass("hover");
                }, function () {
                    $(this).removeClass("hover");
                });
            }
            else {
                thisul.fadeOut("fast");
            }

        });


    </script>
@endsection
